package top.cjwtx.holy.phone.config;//package top.cjwtx.holy.pc.config;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * 自定义密码实现类
 */
public class CredentialMatcher extends SimpleCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
       // MyAuthenticationToken uToken = (MyAuthenticationToken)token;
        UsernamePasswordToken utoken= (UsernamePasswordToken) token;
        //后台传入的密码
        String password  =  new String(utoken.getPassword());
        //获取数据库存放的的密码
        String dbPassword = (String) info.getCredentials();
        boolean equals = this.equals(password, dbPassword);
        return equals;
    }


}
